// components/custom-tabbar/index.js
const app = getApp()
console.log(app.data,"app.data");
console.log(app.data.$language,"app.data.$language");
Component({
  properties: {
    selected: {
      type: Number,
      value: 0,
    },
    language: {
      type: String,
      value: "",
    },
    border: {
      type: Boolean,
      value: false,
    },
  },
  observers: {  
    'language'(newVal, oldVal) {
      if(newVal&&newVal!= this.data.oldVal){
        this.data.oldVal = newVal
        this.initOption()
      }  
     
    }  
  },  
  data: {
    height: 0,
    l201:app.data.$language.l201,
    cfg:{
      "color": "#7B7B7B",
      "selectedColor": "#000",
      "backgroundColor": "#000",
      "borderStyle": "white",
      "custom": true,
      "list": [{
          "pagePath": "pages/home/index",
          "iconPath": "assets/tabbar/home.png",
          "selectedIconPath": "assets/tabbar/home-active.png",
          "text": app.data.$language.l1
        },
        {
          "pagePath": "pages/location/index",
          "iconPath": "assets/tabbar/location.png",
          "selectedIconPath": "assets/tabbar/location-active.png",
          "text": app.data.$language.l2
        },
        {
          "pagePath": "pages/pay/index",
          "iconPath": "assets/tabbar/home.png",
          "selectedIconPath": "assets/tabbar/home-active.png",
          "text": app.data.$language.l201
        },
        {
          "pagePath": "pages/custom/index",
          "iconPath": "assets/tabbar/custom.png",
          "selectedIconPath": "assets/tabbar/custom-active.png",
          "text": app.data.$language.l3
        },
        {
          "pagePath": "pages/me/index",
          "iconPath": "assets/tabbar/me.png",
          "selectedIconPath": "assets/tabbar/me-active.png",
          "text": app.data.$language.l4
        }
      ]
    },
    oldVal:'',
  },
  created() {
  },
methods:{
  initOption(){
    app.languageChange( this.data.language)
    this.setData({
      l201: app.data.$language.l201,
      cfg:{
        "color": "#7B7B7B",
        "selectedColor": "#000",
        "backgroundColor": "#000",
        "borderStyle": "white",
        "custom": true,
        "list": [{
            "pagePath": "pages/home/index",
            "iconPath": "assets/tabbar/home.png",
            "selectedIconPath": "assets/tabbar/home-active.png",
            "text": app.data.$language.l1
          },
          {
            "pagePath": "pages/location/index",
            "iconPath": "assets/tabbar/location.png",
            "selectedIconPath": "assets/tabbar/location-active.png",
            "text": app.data.$language.l2
          },
          {
            "pagePath": "pages/pay/index",
            "iconPath": "assets/tabbar/home.png",
            "selectedIconPath": "assets/tabbar/home-active.png",
            "text": app.data.$language.l201
          },
          {
            "pagePath": "pages/custom/index",
            "iconPath": "assets/tabbar/custom.png",
            "selectedIconPath": "assets/tabbar/custom-active.png",
            "text": app.data.$language.l3
          },
          {
            "pagePath": "pages/me/index",
            "iconPath": "assets/tabbar/me.png",
            "selectedIconPath": "assets/tabbar/me-active.png",
            "text": app.data.$language.l4
          }
        ]
      }
    })
    console.log(this.data.cfg,"222");
  }
}
})